import Vue from "vue"
import Vuex from 'vuex'
Vue.use(Vuex)
import login from './login.js'
import home from './home.js'
import mafa from './maFa.js'
import request from '@/utils/request.js'
import persistence  from '@/js_sdk/uksir-vuex-uniapp-persistence/uksir-vuex-uniapp-persistence/index.js'
const store = new Vuex.Store({
	modules: {
		login,
		home,
		mafa
	},
	state: {
		dd: "111",
		supplierUserId: undefined
	},
	mutations: {
		tt(state) {
			console.log('dd的值为：', state.dd);
		},
		setSupplierUserId(state, userId) {
			state.supplierUserId = userId;
			console.log('用户的userId为：',state.supplierUserId);
		}
	},
	actions: {
		async getinfo(context) {
			await request({
				url: "prod-api/getInfo",
				method: "get",
			}).then((res) => {
				if (res.code < 300) {
					console.log(res);
					context.commit("setSupplierUserId", res.data.user.userId);
				}
			})
		}
	},
	plugins:[persistence ()]
})
export default store
